document.pageRect = function(){
		return { 
			width : this.documentElement.clientWidth,
			height: this.documentElement.clientHeight
		}
	}
	function scrollParent(dom){
			while(true){
				if(dom===document.documentElement)break
				dom = dom.parentElement
				if(dom.scrollHeight==0&&dom.scrollWidth==0)continue
				let c1 = dom.scrollHeight>dom.offsetHeight
				let c2 = dom.scrollWidth>dom.offsetWidth
				if(c1||c2)break
			}
			return dom
		}
		function absOffset(dom){
			let ot = 0
			let ol = 0
			let body = document.body
			let {scrollLeft,scrollTop} = body
			while(true){
				if(dom===body)break
				if(!dom)break
				ot+=dom.offsetTop
				ol+=dom.offsetLeft
				dom = dom.offsetParent
			}
			return {ot,ol}
		}
		function absSt(dom){
			let st = 0
			let sl = 0
			let doc = document.documentElement
			let {scrollLeft,scrollTop} = doc
			while(true){
				if(dom===doc)break
				st+=dom.scrollTop
				sl+=dom.scrollLeft
				dom = dom.parentElement

			}
			st+=scrollTop
			sl+=scrollLeft
			return {
				st,sl
			}
		}
		function ti(){
			
			let imgs = document.querySelectorAll("img")
			imgs = [].filter.call(imgs,img=>{
				return img.offsetWidth>0||img.offsetHeight>0
			})
			let {width,height} = document.pageRect()
			return [].filter.call(imgs,(img)=>{
				let {offsetHeight,
					offsetWidth,
					offsetTop,
					offsetLeft} = img
				let abso = absOffset(img)
				offsetLeft = abso.ol
				offsetTop = abso.ot
				let {st,sl} = absSt(img)
				let c1 = offsetTop-st
				let c2 = offsetLeft-sl
				
				let c10 = c1>=-offsetHeight&&c1<=height&&c2>=-offsetWidth&&c2<=width

				let pe = scrollParent(img)
				let {ol,ot} = absOffset(pe)
				let rx = offsetLeft-ol-pe.scrollLeft
				let ry = offsetTop-ot-pe.scrollTop
				
				let c3 = rx>=-offsetWidth&&rx<=(pe.offsetWidth||pe.scrollWidth)
				let c4 = ry>=-offsetHeight&&ry<=(pe.offsetHeight||pe.scrollHeight)

				let c11 = c3&&c4
				return c10&&c11
			})
		}
		document.addEventListener("click",()=>{
			// let res = tagImg()
			let res = ti()
			console.log(res)
		})